<?php
namespace Api\Utils;

/**
 * Class Arrays
 * @package Api\Utils
 * @author Steffen Brem <steffenbrem@gmail.com>
 */
class Arrays
{
    /**
     * @param array $array
     * @param array $array2
     * @return array
     */
    public static function merge(array $array, array $array2)
    {
        foreach ($array2 as $k => $v)
        {
            if (is_array($v) && isset($array[$k]) && is_array($array[$k]))
            {
                $array[$k] = self::merge($array[$k], $v);
            }
            else
            {
                $array[$k] = $v;
            }
        }

        return $array;
    }

    /**
     * Check if the given array is associative
     *
     * @param array $array
     * @return bool
     */
    public static function isAssoc(array $array)
    {
        return (bool)count(array_filter(array_keys($array), 'is_string'));
    }
}